package com.jokesoft.supermanager.core.entities;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "PERSON")
@NamedQueries({
    @NamedQuery(name = PersonEntity.FETCH_ALL, query = "SELECT p from PersonEntity p")
})
public class PersonEntity {

    public static final String FETCH_ALL = "PersonEntity.fetchAll";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long key;

    @Column
    private String firstName;

    @Column
    private String lastName;

    @Column
    private String role;

    @OneToMany(mappedBy = "personEntity")
    private List<AddressEntity> addressList = new ArrayList<AddressEntity>(0);

    public PersonEntity() {
        // For JPA
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public Long getIdentity() {
        return key;
    }

    public List<AddressEntity> getAddressList() {
        return addressList;
    }

    public void setAddressList(List<AddressEntity> addressList) {
        this.addressList = addressList;
    }

}
